//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Documents
//  File name:	Smart.Documents.EventReceiver.cs
//  Developer:	Solomatov Igor
//  Created:	03.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using System;
using System.Runtime.InteropServices;
using Microsoft.SharePoint;
using Smart.Common;

namespace Smart.Documents.Features
{
	/// <summary>
	/// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
	/// </summary>
	/// <remarks>
	/// The GUID attached to this class may be used during packaging and should not be modified.
	/// </remarks>
	[Guid("678172cb-8810-4b2c-91e5-38eefb1402c3")]
	public class SPDocumentsEventReceiver : SPFeatureReceiver
	{
		public override void FeatureActivated(SPFeatureReceiverProperties properties)
		{
			H.LT("FeatureActivated: Documents");

			try
			{
				var web = (SPWeb) properties.Feature.Parent;

				using (SPH.SetContext(web.Site, web))
				{
					RegisterAddon();
				}
			}
			catch (Exception x)
			{
				H.LX("SPDocumentsEventReceiver.FeatureActivated", x);
			}
		}

		public virtual void RegisterAddon()
		{
			SPServices.AddonManager.Reg(typeof (AddonDocuments).AssemblyQualifiedName);

			// Register and Load addons
			SPServices.AddonManager.Reload();
		}
	}
}